{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "080e62a2-0cef-41ad-b745-b4a00331703b",
   "metadata": {},
   "source": [
    "# Suzuki Trotter\n",
    "\n",
    "The `suzuki_trotter` function produces the Suzuki-Trotter product for a given order and repetitions.\n",
    "\n",
    "Function: `suzuki_trotter`\n",
    "\n",
    "Arguments:\n",
    "\n",
    "- `pauli_operator`: `CArray[PauliTerm]`\n",
    "- `evolution_coefficient`: `CReal`\n",
    "- `order`: `CInt`,\n",
    "- `repetitions`: `CInt`,\n",
    "- `qbv`: `QArray[QBit]`"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e7166188-af15-48c9-96fd-cf4b737e24e5",
   "metadata": {},
   "source": [
    "## Example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "61acbf62-6bd5-4649-a151-6b434915d6ee",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-05-07T13:24:09.866724Z",
     "iopub.status.busy": "2024-05-07T13:24:09.864061Z",
     "iopub.status.idle": "2024-05-07T13:24:14.991054Z",
     "shell.execute_reply": "2024-05-07T13:24:14.990421Z"
    }
   },
   "outputs": [],
   "source": [
    "from classiq import (\n",
    "    CReal,\n",
    "    Output,\n",
    "    Pauli,\n",
    "    PauliTerm,\n",
    "    QArray,\n",
    "    QBit,\n",
    "    allocate,\n",
    "    create_model,\n",
    "    qfunc,\n",
    "    suzuki_trotter,\n",
    "    synthesize,\n",
    "    write_qmod,\n",
    ")\n",
    "\n",
    "\n",
    "@qfunc\n",
    "def main(a: CReal, x: CReal, qba: Output[QArray[QBit]]):\n",
    "    allocate(3, qba)\n",
    "    suzuki_trotter(\n",
    "        [\n",
    "            PauliTerm(pauli=[Pauli.X, Pauli.X, Pauli.Z], coefficient=a),\n",
    "            PauliTerm(pauli=[Pauli.Y, Pauli.X, Pauli.Z], coefficient=0.5),\n",
    "        ],\n",
    "        evolution_coefficient=x,\n",
    "        order=1,\n",
    "        repetitions=1,\n",
    "        qbv=qba,\n",
    "    )\n",
    "\n",
    "\n",
    "qmod = create_model(main)\n",
    "write_qmod(qmod, \"suzuki_trotter\")\n",
    "qprog = synthesize(qmod)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "be631c78-7c6a-4cdf-a968-1a2e6cdefde6",
   "metadata": {},
   "source": [
    "## References\n",
    "\n",
    "<a name=\"Trotter-Suzuki\">[1]</a> N. Hatano and M. Suzuki, Finding Exponential Product Formulas of Higher Orders, (2005). [https://arxiv.org/abs/math-ph/0506007](https://arxiv.org/abs/math-ph/0506007)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
